using System;
using System.ComponentModel;
using System.Data;
using System.Collections.Generic;

namespace PlacementManager
{
    public partial class LinkVenueContactComponent
    {
		//
		// TODO: Add constructor logic here
		//

        [DataObjectMethodAttribute(DataObjectMethodType.Select, false)]
        public List<LinkVenueContact> SelectAllWVenueIdContactId(int VenueId, int ContactId, string sortExpression)
        {
            List<LinkVenueContact> listLinkVenueContact = new List<LinkVenueContact>();
            PlacementManager.DAL.LinkVenueContact_DAL o = new PlacementManager.DAL.LinkVenueContact_DAL();
            o.VenueId = VenueId;
            o.ContactId = ContactId;
            DataSet ds = o.SelectAllWVenueIdContactId();
            foreach (DataRow row in ds.Tables[0].Rows)
            {
                listLinkVenueContact.Add(new LinkVenueContact((int)row["VenueContactId"], (int)row["VenueId"], (int)row["ContactId"], (bool)row["IsPrimary"], (bool)row["IsActive"], (DateTime)row["DateCreated"], (string)row["CreatedBy"], (DateTime)row["DateUpdated"], (string)row["UpdatedBy"]));
            }
            if (sortExpression == string.Empty)
            {
                sortExpression = "DateCreated desc";
            }
            listLinkVenueContact.Sort(new LinkVenueContactComparer(sortExpression));
            return listLinkVenueContact;
        }

        public void SetVenuePrimaryContact(int contactId, int venueId)
        {
            PlacementManager.DAL.LinkVenueContact_DAL o = new PlacementManager.DAL.LinkVenueContact_DAL();
            o.ContactId = contactId;
            o.VenueId = venueId;
            o.SetVenuePrimaryContact();
        }
	}
}
